//
//  MILSenceModeTableViewCell.m
//  MicrowaveInteractionLight
//
//  Created by maple on 2016/12/15.
//  Copyright © 2016年 maple. All rights reserved.
//

#import "MILSenceModeTableViewCell.h"

@implementation MILSenceModeTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark -- 按钮点击
//运行场景
- (IBAction)runSenceClickAction:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(milRunSenceModeButtonClick:)])
    {
        [_delegate milRunSenceModeButtonClick:sender];
    }
}

//删除
- (IBAction)deleteSenceClickAction:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(milDeleteSenceModeButtonClick:)])
    {
        [_delegate milDeleteSenceModeButtonClick:sender];
    }
}

- (void)setSenceModel:(MILSenceModel *)senceModel {
    self.mySenceNameLabel.text = senceModel.name;
    self.mySenceRunTimeLabel.text = [NSString stringWithFormat:@"%@秒",[self getTwinkleWithSliderValue:[senceModel.twinkle intValue]]];
    self.mySenceBrightnessLabel.text = [NSString stringWithFormat:@"亮度：%@%%",senceModel.brightness];
    
    self.deleteBtn.hidden = NO;
    _senceModel = senceModel;
}

- (NSString *)getTwinkleWithSliderValue:(NSInteger)value {
    NSString *string = [[NSString alloc] init];
    
    switch (value) {
            break;
        case 0:
            string = @"0";
            break;
        case 1:
            string = @"0.1s";
            break;
        case 2:
            string = @"0.25s";
            break;
        case 3:
            string = @"0.5s";
            break;
        case 4:
            string = @"1s";
            break;
        case 5:
            string = @"2s";
            break;
        default:
            break;
    }
    return string;
}

@end
